<template>
  <div class='wrap'>
    <div class='container w'>
      <el-card>
        <div slot="header" class="header">
          <div><i class="iconfont icon-pinglun"></i>最新评论</div>
        </div>
        <div class="item" v-for="(item,index) in newComment" :key="index" >
          <div class="avatar-name" @click="$router.push({name: 'User', params: { user_id:`${item.user_id}`}})">
            <el-avatar :size="30" :src="item.comment_user.avatar"></el-avatar>
            <span>{{item.comment_user.nickname}}</span>
          </div>
           <div class="comment">
           <span>{{item.parentId==0 ? "评论" : "回复"}}：</span>
           <!-- @click="$router.push(`/news/details?id=${item.article_id}#comment`)" -->
            <span
            @click="$router.push({name: 'Details', params: { article_id:`${item.article_id}`}})" >
              {{item.content}}
            </span>
           </div>
        </div>
      </el-card>
    </div>
   </div>
</template>

<script>
import { getCommentList } from '@/api/comment'
export default {
  name: 'HotComment',
  components: {},
  data () {
    return {
      newComment: [],
      query: {
        pageNum: 1,
        pageSize: 6
      }
    }
  },
  created () {
    this.getCommentList()
  },
  methods: {
    async getCommentList () {
      const { list, pageNum, pageSize } = await getCommentList(this.query)
      this.query.pageNum = pageNum
      this.query.pageSize = pageSize
      this.newComment = list
    }
  }
}
</script>
<style lang="scss" scoped>
.el-card  {
  box-shadow: 0 2px 8px 0px rgba(122 192 241 / 30%);
  // box-shadow: none;
}
::v-deep .el-card__header{
  padding: 10px 20px;
}
::v-deep .el-card__body{
  padding: 10px 20px
}
.header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  .iconfont{
    color: rgb(76, 141, 238);
    margin-right: 3px;
  }
  .icon-huo{
    font-size: 18px;
  }
}
.avatar-name{
  display: flex;
  align-items: center;
  margin-right: 8px;
  .el-avatar{
    margin:0px;
    margin-right: 5px;
  }
  span:hover{
    color: #6292f0;
    cursor: pointer;
  }
}
.comment{
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  span:nth-child(2):hover{
    color: #6292f0;
    cursor: pointer;
  }
}

  .item:first-child {
     margin-top: 2px;
  }
  .item:last-child {
     margin-bottom: 2px;
  }
.item{
    display: flex;
    align-items: center;
  color: #606266;
  font-size: 15px;
  font-weight: 500;
  margin:20px 0;

}

</style>
